function [R,x_H2,x_SiH4] = UDF1(Gdata)
% reaction model in Kleijn_1989
% The result is based on cell value
% R: kg/m^2*s

MW_SiH4 = 32.11788/1000;
MW_H2 = 2.01594/1000;
MW_Si = 28.086/1000;

% P, y_SiH4 and y_H2 should be cell value
P = Gdata.P;
y_SiH4 = Gdata.y_SiH4;
y_H2 = 1-y_SiH4;

n = y_H2./MW_H2+y_SiH4./MW_SiH4;
x_H2 = (y_H2./MW_H2)./n;
x_SiH4 = (y_SiH4./MW_SiH4)./n;
T_c = Gdata.T_c;
T_f = Gdata.T_n;
x_c = Gdata.x_c;
x_f = Gdata.x_n;
T_f = interp1(x_f,T_f,x_c);

k = 1.6e+4*exp(-18500./T_f);
Kh = 0.19;
Ks = 0.70;

P_SiH4 = P.*x_SiH4;
P_H2 = P.*x_H2;

R = MW_Si.*(k.*P_SiH4)./(1+Kh.*sqrt(P_H2)+Ks.*P_SiH4);